<template>
	<view class="">
		<!-- <view class="uni-page-head" v-if="titleFlag">
			<image class="common-title-img" style="left: 20rpx;"
				:src="require('../../static/imges/fanhui.png')" @click="fanhui()"></image>
				
			<view class="uni-page-head-title">
				贴签说明
			</view>
		</view>
		<view v-if="titleFlag" style="margin-top: 98rpx;">
			这个盒子是用来撑空间，又不想改变下边的body盒子 所以在这加了一个空盒子，可以根据新老MOA判断
		</view> -->
	    <view style="padding-bottom: 60rpx;width: 100%;overflow: hidden;">
			<!-- <uni-table border :stripe="false" emptyText=""  >
				
				<uni-tr  v-for="(item, index) in listatyt">
					<uni-th width="40%"  align="center">物资分类</uni-th>
					<uni-th  width="35%" align="center">物资类型</uni-th>
					<uni-th  width="25%" align="center">标签类型</uni-th>
				</uni-tr>
				
				<uni-tr v-for="(item1, indexer) in item.list">
					<uni-td v-if="indexer==0" :rowspan="imlist[index]" width="40%"   align="center">{{item.name}}</uni-td>
					<uni-td width="35%" align="center">{{item1.materialType}}</uni-td>
					<uni-td width="25%" align="center">{{item1.tagTypeName}}</uni-td>
				</uni-tr>
				
			</uni-table> -->
			<table  v-for="(item, index) in listatyt">
				<tr v-if="index==0">
					<td width="38%" ><text style="font-weight: bold;">物资分类</text></td>
					<td width="40%"><text style="font-weight: bold;">物资类型</text></td>
					<td  width="22%"><text style="font-weight: bold;">标签类型</text></td>
				</tr>
				<tr  v-for="(item1, indexer) in item.list">
					<td v-if="indexer==0" :rowspan="imlist[index]" width="38%" >{{item.name}}</td>
					<td width="40%">{{item1.materialType}}</td>
					<td  width="22%">{{item1.tagTypeName}}</td>
				</tr>
			</table>
		</view>
	
	
	</view>
</template>

<script>
	import talkingdata from '../../common/talkingdata.js';
	import { getGPS, exceedDistance } from "../utils/gpsUtil";
	export default {
	data() {
		return {
			titleFlag:true,
			// lister:[
			// 	{
			// 	"materialCategory": "工程物资(基础设施) ", //物资分类名称    
			// 	"materialType": "地面塔", //物资类型名称
			// 	"tagTypeCode": "6303030103000000000034", //应贴标签物料编码
			// 	"tagTypeName": "打印耗材-标签-RFID标签-A型-室外硬质特种"//应贴标签物料名称
			// 	},
			// 	{
			// 	"materialCategory": "工程物资(基础设施) ", //物资分类名称    
			// 	"materialType": "单管塔", //物资类型名称
			// 	 "tagTypeCode ": "6303030103000000000035",
			// 	"tagTypeName": "打印耗材-标签-RFID标签-B型-柔性抗金属"
				
			// 	}
			// ],
			lister:[],
			listertry:[],
		    listatyt:[],
			imlist:[],
			
		}
		}, 
		onLoad() {
			console.log("执行onLoad")
			if(uni.getStorageSync('moaType')=="0"){
					this.titleFlag=false
			}	
			this.getList();
			 
			 // this.lister.forEach(function(item) {
				//   let index = item.tagTypeName.indexOf("型");
				//  let art=item.tagTypeName.substring(index-1,index+1);
				//  item.tagTypeName=art
			 // });
		  //  this.listertry=this.lister;
		    
			
		},
		onShow() {
		  console.log("执行onShow");
		  getGPS("1","1",this.scanCodeInfo);
		},
		onReady(){
			console.log("执行onReady")
			
			//在页面挂载完成后，调用外部埋点，统计数据
			 // const script= document.createElement('script');
			 // script.type = 'text/javascript';
			 // script.src = talkingdata.talkingKey;
			 // document.body.appendChild(script);
			
		},
		watch:{
			
		},
		methods: {
			
			
			
			// 获取经纬度
			scanCodeInfo(label, index, latitude, longitude){
				 console.log("获取经纬度");
				uni.setStorageSync("latitude",latitude);
				uni.setStorageSync("longitude",longitude);
			},
			fanhui() {
				
				uni.navigateBack({
					delta: 1
				});
			},
			
		
			getList() {
				let that=this;
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				
				uni.request({
					//url: uni.getStorageSync('url') + "/pms/app/tagType/tagTypeList",
					url: uni.getStorageSync("PMS20url") + "/api/app/tagType/tagTypeList",
					method: 'GET',
					dataType: 'json',
					timeout: 10000 * 60,
					header: {
						"sysToken": uni.getStorageSync("PMStoken"),
					},
					data: {},
					success: (res) => {
						uni.hideLoading();
						//console.log('获取项目列表数据:' + JSON.stringify(res));
						console.log('获取项目列表数据:', res.data);
						//console.log('URL:' + uni.getStorageSync('url') + url);
						var data = res.data;
						if(data.resultStat == "000"){
							that.lister=data.data;
							that.lister.forEach(function(item) {
									let index = item.tagTypeName.indexOf("型");
									let art=item.tagTypeName.substring(index-1,index+1);
									item.tagTypeName=art
											 
								});
							that.listertry=that.lister;
							
							
							 var resultArr=[];
							that.listertry.forEach(function(item){
								 
								  resultArr=[...resultArr,item.materialCategory] 
							 })
							  let atyt;
							atyt = resultArr.filter(function (item, index, self) {
							    return self.indexOf(item) == index;
							 });
							
							atyt.forEach(function(item, index, self){
								 that.listatyt.push({
									 name:item,
									 list:[]
								 })
							 })
							
							// 最终筛选
							that.listatyt.forEach(function(item, index, self){
								let arter;
								arter = that.listertry.filter(function (itemer) {
								    return itemer.materialCategory==item.name;
									console.log(itemer,item.name); 
								 }); 
								 item.list=arter;
								 that.imlist.push(arter.length)
							 })
							console.log(that.listatyt); 
							
							
						}else{
							uni.showModal({
							  title: "温馨提示",
							  content: "获取数据失败",
							  showCancel: false,
                confirmColor: '#eb4b4b',
							});
						}
						
			
						uni.hideLoading();
						uni.stopPullDownRefresh();
			
					},
					fail: (data, code) => {
						uni.hideLoading();
						uni.stopPullDownRefresh();
						console.log('fail' + JSON.stringify(data));
					}
				});
			
			},
			
			
			
		},
		}
</script>
<style>
	@import '@/common/common-ui.css';
	.u-search-box {
		width: 100%;
		padding: 18rpx 30rpx;
		background-color: #FFFFFF;
		display: flex;
		
	}
	
	.u-search-inner {
		background-color: rgb(204, 234, 234);
		width: 89%;
		border-radius: 10rpx;
		display: flex;
		align-items: center;
		padding: 10rpx 16rpx;
		background-color: white;
		border:solid 1px gray
	}
	
	.u-search-text {
		font-size: 26rpx;
		color: $u-tips-color;
		margin-left: 10rpx;
	}
	
	.l-label {
		margin-top: 5px;
		margin-left: 10px;
		color: #EB4B4B;
	}
	
	.l_count {
		display: flex;
		justify-content: space-around;
		margin-top: 8px;
	}
	
	.l_text {
		width: 80px;
		text-align: center;
	}
	
</style>
<style scoped lang="scss">
	.u-demo-area {
		
		margin: 0 -40rpx;
	}
	.swiper-item {
		height: 100%;
	
	}
	.swiper-box {
		flex: 1;
		height: 100%;
		margin-top: 160rpx;
	}
	.order {
		width: 710rpx;
		background-color: #ffffff;
		margin: 20rpx auto;
		border-radius: 20rpx;
		box-sizing: border-box;
		padding: 20rpx;
		font-size: 28rpx;
	
		.top {
			display: flex;
			justify-content: space-between;
	        width: 100%;
			.left {
				display: flex;
				align-items: center;
	            
				.store {
					width: 90%;
					margin: 0 10rpx;
					font-size: 28rpx;
					font-weight: bold;
				}
			}
	
			.right {
				display: flex;
				justify-content: flex-end;
				min-width: 33%;
				//color: $u-type-warning-dark;
				.right-title{
					min-width: 170rpx;
					height: 50rpx;
					color: #eb4b4b;
					line-height: 50rpx;
					 text-align: center;
					border: 1px solid #eb4b4b;
					border-radius: 25rpx;
					font-weight: bold;
				}
			}
		}
	
		.item {
			display: flex;
			margin: 20rpx 0 0;
	
			.left {
				margin-right: 20rpx;
	
				image {
					width: 200rpx;
					height: 200rpx;
					border-radius: 10rpx;
				}
			}
	
			.content {
				.title {
					font-size: 28rpx;
					line-height: 50rpx;
				}
	
				.type {
					margin: 10rpx 0;
					font-size: 24rpx;
					color: $u-tips-color;
				}
	
				.delivery-time {
					color: #e5d001;
					font-size: 24rpx;
				}
			}
	
			.right {
				
				margin-left: 10rpx;
				padding-top: 20rpx;
				text-align: right;
	
				.decimal {
					font-size: 24rpx;
					margin-top: 4rpx;
				}
	
				.number {
					color: $u-tips-color;
					font-size: 24rpx;
				}
			}
		}
	
		
	
		
	}
	
	.bss-price-title-text {
		height: 48rpx;
		font-size: 40rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		/* color: #FFFFFF; */
		/* color: #FFFFFF; */
		line-height: 48rpx;
		text-align: left;
	}
	.close-btn {
		// height: 100%;
		margin-top: 50rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		
	}
	.selectBox{
		border: 1rpx solid #c0c4cc;
		position: absolute;
		width: 465rpx;
		z-index: 999;
		background-color: #FFFFFF;
		border-radius: 0 0 10rpx 10rpx;
		padding: 0 0 10px 0;
		
		.selectCell{
			border-bottom: 1rpx solid #FC8C8B;
			text-align: left;
			margin: 0 20rpx;
			font-size: 16px;
			color: #939393;
		}
	}
	.souSuoIcon{
		width: 100rpx;
		height: 74rpx;
		position: absolute;
		right: 33rpx;
		top: 68rpx;
		border-radius: 0 5px 5px 0;
		background: #FB5C5B;
		}
	table{
		width:100%;
		margin: auto;
		border-spacing:0;  
		border-collapse: collapse;
		table-layout: fixed;
		background-color: white;
	}	
	td{
		border:1px solid #ebeef5;
		text-align: center;
		line-height:66rpx ;
	}

</style>
